package com.yanggu.scala.chapater12.if2

object MatchIfDemo01 {

  def main(args: Array[String]): Unit = {
    //字符串默认当成字符数组, 也是可以遍历的
    for (c <- "+-3!") {
      var sign = 0
      var digit = 0
      c match {
        case '+' => sign = 1
        case '-' => sign = -1
        //如果想要匹配某个范围内的数据。需要在模式匹配中新增条件守卫
        case _ if c.toString.equals("3") => digit = 3
        case _ if c > 1110 || c < 120 => println("c > 10")
        case _ => sign = 2
      }
      println(c + "\t" + sign + "\t" + digit)
    }
  }

}
